import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/ui.dart';

class UiMenuItem extends StatelessWidget {
  const UiMenuItem({
    super.key,
    this.text = '菜单',
    this.child,
    this.icon,
    this.iconColor,
    this.backgroundColor,
    this.onTap,
  });
  final String text;
  final Widget? child;
  final IconData? icon;
  final Color? backgroundColor;
  final Color? iconColor;
  final Function()? onTap;
  @override
  Widget build(BuildContext context) {
    return UiTap(
      onTap: onTap,
      child: Container(
        width: 62,
        margin: const EdgeInsets.symmetric(horizontal: 5),
        child: Column(
          children: [
            UiAvatar(
              size: 50,
              radius: 16,
              round: false,
              backgroundColor: backgroundColor ??
                  UiTheme(context).matchColor(
                    UiTheme.primary.withOpacity(0.1),
                    Colors.black.withOpacity(0.2),
                  ),
              child: Padding(
                padding: const EdgeInsets.only(bottom: 2),
                child: child ??
                    UiLinearGradientMask(
                      child: Icon(
                        icon,
                        size: 30,
                        color: iconColor ??
                            UiTheme(context).matchColor(
                              Colors.white,
                              Colors.white,
                            ),
                      ),
                    ),
              ),
            ),
            const SizedBox(height: 5),
            Text(
              text,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              textScaler: const TextScaler.linear(.9),
            ),
          ],
        ),
      ),
    );
  }
}
